#####################################################################
# Product:      KnowledgeEngine (Plone Edition)
#
# File:         AssessmentAttributeHandle.py
#
# Copyright:    Copyright (c) 2005, Faulkner Technologies
#
# Author:       Brian Oliver
#
# Description:  Instances of AssessmentAttributeHandle are used to 
#               uniquely identify a specific 'class' or 'kind' of 
#               AssessmentAttribute that may be associated with
#               Assessments.
#   
#               An AssessmentAttributeHandle captures both the
#               unique identity of the assessment attribute together with
#               the underlying type of value that an AssessmentAttribute
#               stores.
#
#               In order to use an AssessmentAttribute, you will require
#               an AssessmentAttributeHandle
#
# See Also:     AssessmentAttribute, Assessment and AssessmentStorageService
#####################################################################

#####################################################################
## KnowledgeEngine Library Imports
from Common import *

#####################################################################
## Zope Library Imports
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager
from DateTime import DateTime
 
#####################################################################
## Python Library Imports
# (None)

#####################################################################
## AssessmentAttributeHandle Class Definition
class AssessmentAttributeHandle(RoleManager):
    """
        An in-memory representation used to uniquely identify
        AssessmentAttributes.
    """
        
    #---------------------------------------------------------------#

    #declare security so ClassInfo may be accessed in DTML/ZPT etc
    security = ClassSecurityInfo()
    security.declareObjectPublic()
    security.setDefaultAccess("allow")

    #---------------------------------------------------------------#

    def __init__(self, attributeIdentity, valueType, modelIdentity):
        """
            New AssessmentAttribute is constructed using using three properties;
            * The identity of the attribute (String)
            * The type of the value that will be stored (String)
            * The model identity to which the state pertains (String)
        """
               
        ### the following attributes are generally stored together (and need to be persisted)
        self.attributeIdentity = attributeIdentity
        self.modelIdentity = modelIdentity
        self.valueType = valueType                  #(String) see AssessmentComponentValueTypes for defined constants

    #---------------------------------------------------------------#

    def getAttributeIdentity(self):
        """
            Returns the identity of the attribute
            RETURN TYPE: String
        """
        
        return self.attributeIdentity

    #---------------------------------------------------------------#

    def getModelIdentity(self):
        """
            Returns the unique identity for the model that owns the attribute
            RETURN TYPE: String
        """
        
        return self.modelIdentity

    #---------------------------------------------------------------#

    def getValueType(self):
        """
            Returns the type of the value that is stored for this attribute
            
            NOTE: See AssessmentComponentValueTypes for a list of defined contants            
            
            RETURN TYPE: String
        """

        return self.valueType

    #---------------------------------------------------------------#
                
#####################################################################
## Class Initialisation
InitializeClass(AssessmentAttributeHandle)
